package com.carkeeper.userbill.controller;

import com.carkeeper.entity.Result;
import com.carkeeper.entity.StatusCode;
import com.carkeeper.userbill.pojo.UserBill;
import com.carkeeper.userbill.service.UserBillService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/userbill")
public class UserBillController {

    @Autowired
    private UserBillService userBillService;

    /**
     * 分页条件查询
     * @param map
     * @return
     */
    @ApiOperation("分页条件查询")
    @PostMapping("/findByCondition")
    public Result<PageInfo<UserBill>> findByCondition(@RequestBody Map map){
        PageInfo<UserBill> userBillInfo = userBillService.findByCondition(map);
        return new Result<>(true, StatusCode.OK,"",userBillInfo);
    }

    /**
     * 根据账单编码查询账单详细信息
     * @param code
     * @return
     */
    @ApiOperation("根据账单编码查询账单详细信息")
    @GetMapping("/findByCode")
    public Result<UserBill> findByCode(@RequestParam("code") String code){
        Map map = userBillService.findByCode(code);
        return new Result<>(true,StatusCode.OK,"",map);
    }

    /**
     * 账单类型展示列表
     * @return
     */
    @ApiOperation("账单类型展示列表")
    @GetMapping("/findBySubtypeName")
    public Result<List> findBySubtypeName(){
        List list = userBillService.findBySubtypeName();
        return new Result<>(true,StatusCode.OK,"",list);
    }

    /**
     * 支付状态展示列表
     * @return
     */
    @ApiOperation("支付状态展示列表")
    @GetMapping("/findByPayStatus")
    public Result<List> findByPayStatus(){
        List list = userBillService.findByPayStatus();
        return new Result<>(true,StatusCode.OK,"",list);
    }

}
